package api

import (
	"ecommerce-customer-support-chat/api/handler"
	"ecommerce-customer-support-chat/consts"
	"github.com/gin-gonic/gin"
	jwt2 "github.com/golangblogs/gojwt"
)

func LoadRoutes(r *gin.Engine) {
	api := r.Group("/api")
	{
		user := api.Group("/user") //todo:用户模块
		{
			user.POST("/createUser", handler.CreateUser) //注册用户
			user.POST("/loginUser", handler.LoginUser)   //用户登录
		}
		chat := api.Group("/chat") //todo: websocket聊天模块
		{
			chat.Use(jwt2.JWTAuth(consts.JWT_SELECT_KEY))
			chat.GET("/chat", handler.Chat) //websocket聊天
		}
		customerService := api.Group("/customerService") // todo: 客服模块
		{
			customerService.Use(jwt2.JWTAuth(consts.JWT_SELECT_KEY))
			customerService.POST("/userList", handler.UserList) //在线客服列表
		}
		comment := api.Group("/comment") //todo: 查询模块
		{
			comment.Use(jwt2.JWTAuth(consts.JWT_SELECT_KEY))
			comment.POST("/queryComment", handler.QueryComment) //查询聊天
		}
	}
}
